import { _decorator, Color, Component, Graphics, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('CircleRing')
export class CircleRing extends Component {

    private _graphics: Graphics = null;

    init(parent: Node, radius: number, width: number, color: Color) {
        this.node.parent = parent;
        if (this._graphics == null) {
            this._graphics = this.node.addComponent(Graphics);
        }
        this.clear();
        this._graphics.lineWidth = width;
        this._graphics.strokeColor = color;
        this._graphics.circle(0, 0, radius + width / 2);
        this._graphics.stroke();
    }

    clear() {
        this._graphics && this._graphics.clear();
    }
}
